/**
 * author:Administrator
 * date:2013-5-21
 */
package com.roc.web.action.terminal;

import java.sql.Date;
import java.util.ArrayList;
import java.util.List;

import com.roc.page.BaseSearchCondition;
import com.roc.page.WhereHQLFieldBean;
import com.roc.util.Constance;

/**
 * 
 * @author 陈锴
 * 
 * 终端序列号查询
 * 
 * 2014-08-18
 *
 */
public class TermSnInfoSearchCondition extends BaseSearchCondition {
	

	private String orgCode;
	private String agentId;
	private String posBrand;  //品牌
	private String posType;  //机型
	private String posName; //POS名称
	private String isBind;
	private String isUsed;
	
	

	/* (non-Javadoc)
	 * @see com.roc.page.BaseSearchCondition#getOrderPartOfHQL()
	 */
	@Override
	protected String getOrderPartOfHQL() {
		// TODO Auto-generated method stub
		
		return " order by a.dt_create desc ";
	}

	/* (non-Javadoc)
	 * @see com.roc.page.BaseSearchCondition#getRowCountHQL()
	 */
	@Override
	protected String getRowCountHQL() {//,OrgBean o  t.orgCode = o.org_code
		StringBuffer sb=new StringBuffer();
		sb.append(" SELECT COUNT(*) ");
		sb.append(" FROM yj_pos_info i ");
		sb.append(" INNER JOIN yj_pos_agent a ");
		sb.append(" ON i.serial_num = a.serial_num ");
		sb.append(" WHERE 1=1 ");
		return sb.toString();
	}

	/* (non-Javadoc)
	 * @see com.roc.page.BaseSearchCondition#getSearchHQL()
	 */
	@Override
	protected String getSearchHQL() {
		StringBuffer sb=new StringBuffer();
		sb.append(" SELECT i.serial_num,i.pos_brand,i.pos_type,i.pos_name,i.org_code,i.is_bind,a.is_used ");
		sb.append(" FROM yj_pos_info i ");
		sb.append(" INNER JOIN yj_pos_agent a ");
		sb.append(" ON i.serial_num = a.serial_num ");
		sb.append(" WHERE 1=1 ");
		return sb.toString(); //y.isBind = 'N'
	}

	/* (non-Javadoc)
	 * @see com.roc.page.BaseSearchCondition#getWhereHQLFieldBeanList()
	 */
	@Override
	protected List<WhereHQLFieldBean> getWhereHQLFieldBeanList() {
		List<WhereHQLFieldBean> filedBeanList = new ArrayList<WhereHQLFieldBean>();

		

		if (Constance.isNotEmpty(posBrand)) {
			filedBeanList.add(new WhereHQLFieldBean("i.pos_brand", posBrand, "=", false));
		}
		if (Constance.isNotEmpty(posType)) {
			filedBeanList.add(new WhereHQLFieldBean("i.pos_type", posType, "=", false));
		}
		if (Constance.isNotEmpty(posName)) {
			filedBeanList.add(new WhereHQLFieldBean("i.pos_name", posName, "=", false));
		}
		if (Constance.isNotEmpty(agentId)) {
			filedBeanList.add(new WhereHQLFieldBean("a.agent_id", agentId, "=", false));
		}
		if (Constance.isNotEmpty(isBind) && !isBind.equals("99")) {
			filedBeanList.add(new WhereHQLFieldBean("i.is_bind", isBind, "=", false));
		}
		if (Constance.isNotEmpty(isUsed) && !isUsed.equals("99")) {
			filedBeanList.add(new WhereHQLFieldBean("a.is_used", isUsed, "=", false));
		}
		
		return filedBeanList;
	}


	public String getOrgCode() {
		return orgCode;
	}

	public void setOrgCode(String orgCode) {
		this.orgCode = orgCode;
	}

	public String getPosBrand() {
		return posBrand;
	}

	public void setPosBrand(String posBrand) {
		this.posBrand = posBrand;
	}

	public String getPosType() {
		return posType;
	}

	public void setPosType(String posType) {
		this.posType = posType;
	}

	public String getPosName() {
		return posName;
	}

	public void setPosName(String posName) {
		this.posName = posName;
	}

	public String getAgentId() {
		return agentId;
	}

	public void setAgentId(String agentId) {
		this.agentId = agentId;
	}

	public String getIsBind() {
		return isBind;
	}

	public void setIsBind(String isBind) {
		this.isBind = isBind;
	}

	public String getIsUsed() {
		return isUsed;
	}

	public void setIsUsed(String isUsed) {
		this.isUsed = isUsed;
	}

}
